<a href='https://github.com/angular/angular.js/edit/v1.8.x/src/ngMock/browserTrigger.js?message=docs(browserTrigger)%3A%20describe%20your%20change...#L4' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this Doc</a>



<a href='https://github.com/angular/angular.js/tree/v1.8.2/src/ngMock/browserTrigger.js#L4' class='view-source pull-right btn btn-primary'>
  <i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source
</a>


<header class="api-profile-header">
  <h1 class="api-profile-header-heading">browserTrigger</h1>
  <ol class="api-profile-header-structure naked-list step-list">
    
    <li>
      - function in module <a href="api/ngMock">ngMock</a>
    </li>
  </ol>
</header>





<div class="api-profile-description">
  <h2 id="overview">Overview</h2>
  <p>This is a global (window) function that is only available when the <a href="api/ngMock"><code>ngMock</code></a> module is
included.</p>
<p>It can be used to trigger a native browser event on an element, which is useful for unit testing.</p>

</div>




<div>
  

  

  <h2 id="usage">Usage</h2>
    
      <p><code>browserTrigger(element, [eventType], [eventData]);</code></p>


    

    
<section class="api-section">
  <h3 id="browserTrigger-arguments">Arguments</h3>

<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        element
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-object">Object</a>
      </td>
      <td>
        <p>Either a wrapped jQuery/jqLite node or a DOMElement</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        eventType
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-string">string</a>
      </td>
      <td>
        <p>Optional event type. If none is specified, the function tries
                           to determine the right event type for the element, e.g. <code>change</code> for
                           <code>input[text]</code>.</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        eventData
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-object">Object</a>
      </td>
      <td>
        <p>An optional object which contains additional event data that is used
                           when creating the event:</p>
<ul>
<li><p><code>bubbles</code>: <a href="https://developer.mozilla.org/docs/Web/API/Event/bubbles">Event.bubbles</a>.
Not applicable to all events.</p>
</li>
<li><p><code>cancelable</code>: <a href="https://developer.mozilla.org/docs/Web/API/Event/cancelable">Event.cancelable</a>.
Not applicable to all events.</p>
</li>
<li><p><code>charcode</code>: <a href="https://developer.mozilla.org/docs/Web/API/KeyboardEvent/charcode">charCode</a>
for keyboard events (keydown, keypress, and keyup).</p>
</li>
<li><p><code>data</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent/data">data</a> for
<a href="https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent">CompositionEvents</a>.</p>
</li>
<li><p><code>elapsedTime</code>: the elapsedTime for
<a href="https://developer.mozilla.org/docs/Web/API/TransitionEvent">TransitionEvent</a>
and <a href="https://developer.mozilla.org/docs/Web/API/AnimationEvent">AnimationEvent</a>.</p>
</li>
<li><p><code>keycode</code>: <a href="https://developer.mozilla.org/docs/Web/API/KeyboardEvent/keycode">keyCode</a>
for keyboard events (keydown, keypress, and keyup).</p>
</li>
<li><p><code>keys</code>: an array of possible modifier keys (ctrl, alt, shift, meta) for
<a href="https://developer.mozilla.org/docs/Web/API/MouseEvent">MouseEvent</a> and
keyboard events (keydown, keypress, and keyup).</p>
</li>
<li><p><code>relatedTarget</code>: the
<a href="https://developer.mozilla.org/docs/Web/API/MouseEvent/relatedTarget">relatedTarget</a>
for <a href="https://developer.mozilla.org/docs/Web/API/MouseEvent">MouseEvent</a>.</p>
</li>
<li><p><code>which</code>: <a href="https://developer.mozilla.org/docs/Web/API/KeyboardEvent/which">which</a>
for keyboard events (keydown, keypress, and keyup).</p>
</li>
<li><p><code>x</code>: x-coordinates for <a href="https://developer.mozilla.org/docs/Web/API/MouseEvent">MouseEvent</a>
and <a href="https://developer.mozilla.org/docs/Web/API/TouchEvent">TouchEvent</a>.</p>
</li>
<li><p><code>y</code>: y-coordinates for <a href="https://developer.mozilla.org/docs/Web/API/MouseEvent">MouseEvent</a>
and <a href="https://developer.mozilla.org/docs/Web/API/TouchEvent">TouchEvent</a>.</p>
</li>
</ul>

        
      </td>
    </tr>
    
  </tbody>
</table>

</section>
    

    

  
  
  



  
</div>


